package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.WC;

import java.util.Arrays;

/**
 * @author tzp
 * @since 2020/9/27
 */
public class WC208_2 implements WC {
    public int minOperationsMaxProfit(int[] customers, int boardingCost, int runningCost) {
        if (customers == null || customers.length == 0 || runningCost >= boardingCost * 4) return -1;
        int sum = Arrays.stream(customers).sum();
        System.out.println("sum: " + sum);
        System.out.println("/ : " + (int) sum / 4.0);
        System.out.println("% : " + (int) sum % 4.0);

        int rotate = 0, remainCustom = 0;
        for (int i = 0; i < customers.length; i++) {
            int allCustomNow = remainCustom + customers[i];
            if (allCustomNow < 4 && i < customers.length - 1) {
                remainCustom = allCustomNow;
                System.out.println("wait");
            } else {
                int boardCustom = Math.min(4, allCustomNow);
                if (boardingCost * boardCustom > runningCost) {
                    rotate++;
                    remainCustom = allCustomNow - boardCustom;
                    System.out.println("rotate");
                } else {
                    remainCustom = allCustomNow;
                    System.out.println("wait");
                }
            }
        }
        while (remainCustom > 0) {
            int boardCustom = Math.min(4, remainCustom);
            rotate++;
            remainCustom = remainCustom - boardCustom;
            System.out.println("rotate");
            if (boardingCost * boardCustom > runningCost) {
            } else {
            }
        }

        return rotate;
    }

    public static void main(String[] args) {
        System.out.println(new WC208_2().minOperationsMaxProfit(new int[]{10, 10, 6, 4, 7}, 3, 8));//9
//        System.out.println(new WC208_2().minOperationsMaxProfit(new int[]{8, 3}, 5, 6));//
//        System.out.println(new WC208_2().minOperationsMaxProfit(new int[]{8, 5}, 5, 6));//
//        System.out.println(new WC208_2().minOperationsMaxProfit(new int[]{8, 2, 1, 1}, 5, 6));//
//        System.out.println(new WC208_2().minOperationsMaxProfit(new int[]{4, 2, 1, 1}, 5, 6));//
        int[] a = {0, 43, 37, 9, 23, 35, 18, 7, 45, 3, 8, 24, 1, 6, 37, 2, 38, 15, 1, 14, 39, 27, 4, 25, 27, 33, 43, 8, 44, 30, 38, 40, 20, 5, 17, 27, 43, 11, 6, 2, 30, 49, 30, 25, 32, 3, 18, 23, 45, 43, 30, 14, 41, 17, 42, 42, 44, 38, 18, 26, 32, 48, 37, 5, 37, 21, 2, 9, 48, 48, 40, 45, 25, 30, 49, 41, 4, 48, 40, 29, 23, 17, 7, 5, 44, 23, 43, 9, 35, 26, 44, 3, 26, 16, 31, 11, 9, 4, 28, 49, 43, 39, 9, 39, 37, 7, 6, 7, 16, 1, 30, 2, 4, 43, 23, 16, 39, 5, 30, 23, 39, 29, 31, 26, 35, 15, 5, 11, 45, 44, 45, 43, 4, 24, 40, 7, 36, 10, 10, 18, 6, 20, 13, 11, 20, 3, 32, 49, 34, 41, 13, 11, 3, 13, 0, 13, 44, 48, 43, 23, 12, 23, 2};
        System.out.println(new WC208_2().minOperationsMaxProfit(a, 43, 54));//993
    }
}
